@extends('admin.common.main')
@section('css')
<style>
</style>
@endsection
@section('cnt')
<div class="x-body">
    @include('admin.common.validate')
    @include('admin.common.msg')
    <button class="layui-btn" onclick="javascript:history.go(-1);">返回</button>
    <form class="layui-form" action="{{ route('admin.user.update',$model) }}" method="post" id="form-member-add">
        {{ csrf_field() }}
        {{ method_field('PUT') }}
        <div class="layui-form-item">
            <label for="username" class="layui-form-label">
                <span class="x-red">*</span>账号
            </label>
            <div class="layui-input-inline">
                <div style="margin-top: 10px;">{{ $model->username }}</div>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="truename" class="layui-form-label">
                <span class="x-red">*</span>姓名
            </label>
            <div class="layui-input-inline">
                <input type="text" id="truename" name="truename" autocomplete="off" class="layui-input" value="{{ $model->truename }}">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="phone" class="layui-form-label">
                <span class="x-red">*</span>手机
            </label>
            <div class="layui-input-inline">
                <input type="text" id="phone" name="phone" autocomplete="off" class="layui-input" value="{{ $model->phone }}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="x-red">*</span>角色</label>
            <div class="layui-input-block">
                <input type="radio" name="sex" lay-skin="primary" title="先生" value="先生" @if($model->sex == '先生')checked="checked"@endif>
                <input type="radio" name="sex" lay-skin="primary" title="女士" value="女士" @if($model->sex == '女士')checked="checked"@endif>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_email" class="layui-form-label">
                <span class="x-red"></span>邮箱
            </label>
            <div class="layui-input-inline">
                <input type="email" id="email" name="email" autocomplete="off" class="layui-input" value="{{ $model->email }}">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="L_repass" class="layui-form-label">
            </label>
            <button class="layui-btn" type="submit">
                修改用户
            </button>
        </div>
    </form>
</div>
@endsection
@section('js')
<script type="text/javascript" src="/admin/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="/admin/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="/admin/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script>
    $("#form-member-add").validate({
        //规则
        rules: {
            //表单元素名称
            username: {
                required: true
            },
            truename: {
                required: true
            },
            phone: {
                phone: true
            },
            email: {
                email: true
            }
        },
        messages: {
            username: "请输入用户名",
            truename: "请输入姓名",
        },
        onkeyup: false,
        success: "valid",
        submitHandler: function(form) {
            console.log(form)
            form.submit();
        }
    });



    //自定义验证规则
    jQuery.validator.addMethod("phone", function(value, element) {
        var reg1 = /^\+86-1[3-9]\d{9}$/;
        var reg2 = /^1[3-9]\d{9}$/;
        var ret = reg1.test(value) || reg2.test(value);
        return this.optional(element) || ret;
    }, "请输入正确的手机号码");
</script>
@endsection